public class CreateActivity {

    public String caseId{get;set;}
    public String casenumber{get;set;}
    public String accountname{get;set;}
    public String contactid{get;set;}
    public String email{get;set;}
    public Task newtask{get;set;}
    public Event newevent{get;set;}
    public string userid{get;set;}
     
    public CreateActivity(){
        caseId=ApexPages.currentPage().getParameters().get('id');
        
        newtask=new Task();
        newevent=new Event();
        userid=userInfo.getuserId();
        Case c=[select CaseNumber,Account.Name,Contact.Id,Account.PersonEmail from Case where id=:caseId];
        casenumber=c.CaseNumber;
        contactid=c.Contact.Id;
        accountname=c.Account.Name;
        email=c.Account.PersonEmail;
    }
    
    public PageReference Cancel(){
   
       PageReference reference=new PageReference('/apex/Casedetailpage?id='+caseId);
       reference.setredirect(true);
       return reference;
   
   }
   
   public pagereference Createtasks(){
   
       newtask.WhoId=contactid;
       newtask.WhatId=caseid;
       newtask.OwnerId=userid;
       insert newtask; 
       PageReference reference=new PageReference('/apex/Casedetailpage?id='+caseId);  
       reference.setredirect(true);
       return reference;
   }
    
}